package com.zhledu.algorithm;


import java.util.Scanner;

public class 三角形 {

  private  static int Max(int a,int b){
    return a>b?a:b;
  }
  public static void main(String[] args) {
    Scanner scanner=new Scanner(System.in);
    int n=scanner.nextInt();
    int array[][]=new int[n+1][n+1];
    for(int i=1;i<=n;i++){
      for(int j=1;j<=i;j++){
        array[i][j]= scanner.nextInt();
      }
    }

    for(int i=1;i<=n;i++){
      for(int j=1;j<=i;j++){
        int max = Max(array[i - 1][j - 1],array[i - 1][j]);
        array[i][j] += max;
      }
    }

    if(n%2==1){
      System.out.println(array[n][n/2+1]);
    }else{
      System.out.println(Max(array[n][n/2],array[n][n/2+1]));
    }
  }
}
